const {
  Book
} = require("../model/model.js");

const BookDao = {
  //保存职位数据
  save(positionInfo) {
    const book = new Book(positionInfo);
    return book.save();
  },
  findByPage(page) {
    const pageSize = 5;
    //返回query对象
    return Book.find({}).limit(pageSize).skip((page - 1) * pageSize);
  },
  deleteById(id) {
    return Book.deleteOne({
      _id: id
    });
  },
  updateById(data) {
    return Book.update({
      _id: data.id
    }, {
      logo: data.logo,
      bookname: data.bookname,
      bookwriter: data.bookwriter,
      bookaomunt: data.bookaomunt
    });
  }
}

module.exports = BookDao;
